public class PalindromeList {
    public boolean chkpalindrome(ListNode A){
        ListNode fast=A;
        ListNode slow=A;
        if (A==null)
            return false;

        while(fast!=null&&fast.next!=null){
            fast=fast.next.next;
            slow=slow.next;
        }
        ListNode cur=slow.next;
        while(cur!=null){
            ListNode lin=cur.next;
            cur.next=slow;
            slow=cur;
            cur=lin;
        }
        int len=0;
        while(A!=slow&&len<A.size()/2){
            if (A.val!=slow.val)
                return false;
            len++;

            A=A.next;
            slow=slow.next;
        }
        return true;
    }
}
